<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>元素的碎片</title>
</head>
<body>
    <ul id="a">
        <li>apple1</li>
        <li>apple2</li>
        <li>apple3</li>
    </ul>
    <ul id="b"></ul>
    <script>
        //创建节点碎片
        var fragment = document.createDocumentFragment();
        //
        var ul = document.querySelector('#a');
        while(ul.firstChild){
            //存在字节点则插入节点碎片
            fragment.appendChild(ul.firstChild);
        }
        var ulb = document.querySelector('#b');
        //将节点碎片插入ul b中
        ulb.appendChild(fragment)
        console.log(fragment)
        console.log(ul)

    </script>
</body>
</html>